<template>
     <el-tree 
      :data="datamy" 
      show-checkbox
      :props="defaultProps" 
      node-key="id"
      default-expand-all
       ref="tree">
    </el-tree>
</template>
<script>
import { recommended } from '@/api/user';
export default { 
    props:['da'],
    data(){
        return{
        defaultProps: { children: 'children',  label: 'label'},
        id:4,
        expkey:[],
        datamy:[],
        tree:[],
         teep:{vue:4,id:0}
        };
    },
    created() {
      // this.TreeRefresh();
     },
   methods:{
     TreeRefresh(val){
       this.datamy=[];
       this.expkey=[],
       this.teep.id=val;
        recommended(this.teep).then(rsp => {
        if (rsp.errcode === 0) {
          let da=rsp.data
            this.datamy=rsp.data;       // this.$message.success(this.id.toString());
           this.expkey = [this.id];     
        }
      });
    },
    getCheckedKeys(){
      this.tree=this.$refs.tree.getCheckedKeys()
       this.$emit('change',this.tree); //返回整个数组
    },
    setCheckedKeys(value) {
     // console.log("value",value)
       this.$refs.tree.setCheckedKeys(value); 
     }
   }  
}
</script>

